package com.ruoyi.services.service.impl;

import java.util.Date;
import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.enums.FeeAndRepairStatus;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.services.mapper.ComplaintOnlineMapper;
import com.ruoyi.services.domain.ComplaintOnline;
import com.ruoyi.services.service.IComplaintOnlineService;

/**
 * 在线投诉Service业务层处理
 *
 * @author ruoyi
 * @date 2023-10-20
 */
@Service
public class ComplaintOnlineServiceImpl implements IComplaintOnlineService
{
    @Autowired
    private ComplaintOnlineMapper complaintOnlineMapper;

    /**
     * 查询在线投诉
     *
     * @param id 在线投诉主键
     * @return 在线投诉
     */
    @Override
    public ComplaintOnline selectComplaintOnlineById(Long id)
    {
        return complaintOnlineMapper.selectComplaintOnlineById(id);
    }

    /**
     * 查询在线投诉列表
     *
     * @param complaintOnline 在线投诉
     * @return 在线投诉
     */
    @Override
    @DataScope(deptAlias = "d",userAlias = "u")
    public List<ComplaintOnline> selectComplaintOnlineList(ComplaintOnline complaintOnline) {
        return complaintOnlineMapper.selectComplaintOnlineList(complaintOnline);
    }

    /**
     * 新增在线投诉
     *
     * @param complaintOnline 在线投诉
     * @return 结果
     */
    @Override
    public int insertComplaintOnline(ComplaintOnline complaintOnline)
    {
        complaintOnline.setComplaintDate(new Date());
        complaintOnline.setUserId(SecurityUtils.getUsername());
        complaintOnline.setStatus(FeeAndRepairStatus.INPROCESS.getCode());
        return complaintOnlineMapper.insertComplaintOnline(complaintOnline);
    }

    /**
     * 修改在线投诉
     *
     * @param complaintOnline 在线投诉
     * @return 结果
     */
    @Override
    public int updateComplaintOnline(ComplaintOnline complaintOnline)
    {
        return complaintOnlineMapper.updateComplaintOnline(complaintOnline);
    }

    /**
     * 批量删除在线投诉
     *
     * @param ids 需要删除的在线投诉主键
     * @return 结果
     */
    @Override
    public int deleteComplaintOnlineByIds(Long[] ids)
    {
        return complaintOnlineMapper.deleteComplaintOnlineByIds(ids);
    }

    /**
     * 删除在线投诉信息
     *
     * @param id 在线投诉主键
     * @return 结果
     */
    @Override
    public int deleteComplaintOnlineById(Long id)
    {
        return complaintOnlineMapper.deleteComplaintOnlineById(id);
    }
}
